POV-Ray : Newsgroups : povray.general : Problems with the sum() and prod(). (Bug in v3.5 ?) : Problems with the sum() and prod(). (Bug in v3.5 ?) Server Time
5 Aug 2024 00:19:11 EDT (-0400)
  Problems with the sum() and prod(). (Bug in v3.5 ?)  
From: Tor Olav Kristensen
Date: 9 Jan 2003 21:10:03
Message: <web.3e1e2ad581e209a5b417814a0@news.povray.org>
If I have understood the documentation
for the new sum() and prod() functions
right, then POV-Ray v3.5 for Windows
behaves very oddly in some cases.

I have observed two different beahiours:

1)
When I run some code with these
functions, POV-Ray just "hangs" and
does not finish parsing, even if the
calculations are very short. In this
state it does not react when I press
the Stop button.

When I try to close it down, then it
says "POV-Ray is currently rendering -
do you want to stop ?".

If I answer Yes, then POV-Ray closes
down as it should. If I answer No,
then POV-Ray just continues to "hang".

The Pause button is working OK.

2)
When I run some other code with these
functions, POV-Ray finishes but
produces wrong results.


Can anyone confirm this behaviour ?

I have inserted my test code below.

The relevant documentation is here:
http://www.povray.org/documentation/view/140/
(Section 6.1.6.1)

My PC runs Win98SE and has a 166MHz MMX
Pentium processor with 96MB of RAM.


Tor Olav


#version 3.5;


// Test of sum() function

// Hangs. Should have given 1.233701
 #declare Fn = function(x) { sum(i, 1, 2, atan2(1, 1)*atan2(1, 1)) }

// Hangs. Should have given 0
// #declare Fn = function(x) { sum(i, 1, 2, pow(x, i) + pow(x, i)) }

// Hangs. Should have given 0
// #declare Fn = function(x) { sum(i, 1, 2, pow(x, 2)*pow(x, 2)) }

// Hangs. Should have given 4
// #declare Fn = function(x) { sum(i, 1, 2, pow(1, 2) + pow(1, 2)) }

// Finishes, but with wrong result: 66 instead of 17
// #declare Fn = function(x) { sum(i, 1, 2, pow(i, 2)*pow(i, 2)) }

// Finishes, but with wrong result: 2.826822 instead of 1.534895
// #declare Fn = function(x) { sum(i, 1, 2, sin(i)*sin(i)) }

// Finishes, but with wrong result: 2 instead of 0
// #declare Fn = function(x) { sum(i, 1, 2, sin(x)*sin(x)) }


// Test of prod() function

// Hangs. Should have given 0.380504
// #declare Fn = function(x) { prod(i, 1, 2, atan2(1, 1)*atan2(1, 1)) }

// Hangs. Should have given 0
// #declare Fn = function(x) { prod(i, 1, 2, pow(x, i) + pow(x, i)) }

// Hangs. Should have given 0
// #declare Fn = function(x) { prod(i, 1, 2, pow(x, 2)*pow(x, 2)) }

// Hangs. Should have given 4
// #declare Fn = function(x) { prod(i, 1, 2, pow(1, 2) + pow(1, 2)) }

// Finishes, but with wrong result: 128 instead of 16
// #declare Fn = function(x) { prod(i, 1, 2, pow(i, 2)*pow(i, 2)) }

// Finishes, but with wrong result: 1.653644 instead of 0.585451
// #declare Fn = function(x) { prod(i, 1, 2, sin(i)*sin(i)) }

// Finishes with correct result: 0, but gives wrong result for Fn(1)
// #declare Fn = function(x) { prod(i, 1, 2, sin(x)*sin(x)) }



// #declare SumFn = function(A, B) { A + B } // Uncomment for tests below


// Test of sum() function

// Hangs. Should have given 18
// #declare Fn = function(x) { sum(i, 1, 2, SumFn(i, 1)*SumFn(i, 2)) }

// Finishes, but with wrong result: 3 instead of 4
// #declare Fn = function(x) { sum(i, 1, 2, SumFn(x, 1)*SumFn(x, 2)) }

// Finishes, but with wrong result: 4 instead of 7
// #declare Fn = function(x) { sum(i, 1, 2, SumFn(x, 1)*SumFn(i, 2)) }


// Test of prod() function

// Hangs. Should have given 72
// #declare Fn = function(x) { prod(i, 1, 2, SumFn(i, 1)*SumFn(i, 2)) }

// Finishes, but with wrong result: 2 instead of 4
// #declare Fn = function(x) { prod(i, 1, 2, SumFn(x, 1)*SumFn(x, 2)) }

// Finishes, but with wrong result: 3 instead of 12
// #declare Fn = function(x) { prod(i, 1, 2, SumFn(x, 1)*SumFn(i, 2)) }



#debug "\n"
#debug str(Fn(0), 0, -1)
#debug "\n\n"


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.